<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Serenity
 * Date: 20-6-11
 * Time: 10:03
 * To change this template use File | Settings | File Templates.
 */
require_once(Config::acquire('Controller', null, 'controller'));
class LoginController extends Controller
{

    /**
     * Index:
     * Hier wordt in het kort info gegeven.
     * @return void
     */
    public function index()
    {
        $this->view->assign('form_URL', SDS::getURL('login', 'submit', null));
        $this->view->render('Login.tpl');
    }

    /**
     * Dit zijn de inlog velden en de controle over deze velden.
     */
    public function submit()
    {

        require_once(Config::acquire('Medewerker', MODEL));
        require_once(Config::acquire('FormValidation', APPLICATION));

        FormValidation::stripInput();
        if (is_bool(Medewerker::authenticate($_POST['username'], $_POST['password'])))
            SDS::redirect('login', 'succes', null);
        else
            SDS::redirect('login', '', Medewerker::authenticate($_POST['username'], $_POST['password']));
        return;
    }

    /**
     * Uitloggen
     * alle sessions worden gesloten.
     */
    public function logout()
    {
        session_unset();
        session_destroy();

        Register::unset_regiseter(null, true);
        SDS::redirect('login', null);
    }

    /**
     * na inloggen krijg je het scherm met succesvol ingelogd
     */
    public function succes()
    {
        $this->view->render('LoginSucces.tpl');
    }


    public function add()
    {
       SDS::redirect("Login","index",null);
    }

    public function bewerken()
    {
          SDS::redirect("Login","index",null);
    }

    public function delete()
    {
          SDS::redirect("Login","index",null);
    }

    public function overzicht()
    {
          SDS::redirect("Login","index",null);
    }

    public function toevoegen()
    {
          SDS::redirect("Login","index",null);
    }

    public function update()
    {
          SDS::redirect("Login","index",null);
    }
}